home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / OWLCTL.ZIP;1 / UTY25002.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-11  |  3.2 KB  |  99 lines

  1. #include <windows.h>
  2. #include <uty25002.h>
  3.  
  4. //
  5. //  LoadUIBitmap() - load a bitmap resource
  6. //
  7. //      load a bitmap resource from a resource file, converting all
  8. //      the standard UI colors to the current user specifed ones.
  9. //
  10. //      this code is designed to load bitmaps used in "gray ui" or
  11. //      "toolbar" code.
  12. //
  13. //      the bitmap must be a 4bpp windows 3.0 DIB, with the standard
  14. //      VGA 16 colors.
  15. //
  16. //      the bitmap must be authored with the following colors
  17. //
  18. //          Window Text        Black        (index 0)
  19. //          Button Shadow      gray         (index 7)
  20. //          Button Face        lt gray      (index 8)
  21. //          Button Highlight   white        (index 15)
  22. //          Window Color       yellow       (index 11)
  23. //          Window Frame       green        (index 10)
  24. //
  25. //      Example:
  26. //
  27. //          hbm = LoadUIBitmap(hInstance, "TestBmp",
  28. //              GetSysColor(COLOR_WINDOWTEXT),
  29. //              GetSysColor(COLOR_BTNFACE),
  30. //              GetSysColor(COLOR_BTNSHADOW),
  31. //              GetSysColor(COLOR_BTNHIGHLIGHT),
  32. //              GetSysColor(COLOR_WINDOW),
  33. //              GetSysColor(COLOR_WINDOWFRAME));
  34. //
  35. //      Author:     JimBov, ToddLa
  36. //
  37. //
  38.  
  39. HBITMAP PASCAL  LoadUIBitmap(
  40.     HINSTANCE      hInstance,          // EXE file to load resource from
  41.     LPSTR      szName,             // name of bitmap resource
  42.     COLORREF    rgbText,            // color to use for "Button Text"
  43.     COLORREF    rgbFace,            // color to use for "Button Face"
  44.     COLORREF    rgbShadow,          // color to use for "Button Shadow"
  45.     COLORREF    rgbHighlight,       // color to use for "Button Hilight"
  46.     COLORREF    rgbWindow,          // color to use for "Window Color"
  47.     COLORREF    rgbFrame)           // color to use for "Window Frame"
  48. {
  49.     LPBYTE              lpb;
  50.     HBITMAP             hbm;
  51.     LPBITMAPINFOHEADER  lpbi;
  52.     HANDLE              h;
  53.     HDC                 hdc;
  54.     LPDWORD             lprgb;
  55.  
  56.     // convert a RGB into a RGBQ
  57.     #define RGBQ(dw) RGB(GetBValue(dw),GetGValue(dw),GetRValue(dw))
  58.  
  59.     h = LoadResource(hInstance,FindResource(hInstance, szName, RT_BITMAP));
  60.  
  61.     lpbi = (LPBITMAPINFOHEADER)LockResource(h);
  62.  
  63.     if (!lpbi)
  64.         return(NULL);
  65.  
  66. #ifdef NOTNEEDEDFORCTL3D
  67.     if (lpbi->biSize != sizeof(BITMAPINFOHEADER))
  68.         return NULL;
  69.  
  70.     if (lpbi->biBitCount != 4)
  71.         return NULL;
  72. #endif
  73.  
  74.     lprgb = (LPDWORD)((LPBYTE)lpbi + (int)lpbi->biSize);
  75.     lpb   = (LPBYTE)(lprgb + 16);
  76.  
  77.     /*
  78.     lprgb[0]  = RGBQ(rgbText);          // Black
  79.     lprgb[7]  = RGBQ(rgbFace);          // lt gray
  80.     lprgb[8]  = RGBQ(rgbShadow);        // gray
  81. //    lprgb[7]  = RGBQ(rgbShadow);        // gray
  82. //    lprgb[8]  = RGBQ(rgbFace);          // lt gray
  83.     lprgb[15] = RGBQ(rgbHighlight);     // white
  84.     */
  85.     lprgb[11] = RGBQ(rgbWindow);        // yellow
  86.     lprgb[10] = RGBQ(rgbFrame);         // green
  87.  
  88.     hdc = GetDC(NULL);
  89.  
  90.     hbm = CreateDIBitmap(hdc, lpbi, CBM_INIT, (LPVOID)lpb,
  91.         (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
  92.  
  93.     ReleaseDC(NULL, hdc);
  94.     UnlockResource(h);
  95.     FreeResource(h);
  96.  
  97.     return(hbm);
  98. }
  99.